/* Copyright 2015 David Overeem (dovereem@cox.net)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * 
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package org.xtce.apps.editor.ui;

import javax.swing.JScrollPane;
import org.xtce.toolkit.XTCESpaceSystem;

/**
 *
 * @author David Overeem
 *
 */

public final class XTCEViewerSpaceSystemDetails extends javax.swing.JPanel {

    /**
     * Creates new form XTCEViewerSpaceSystemDetails TODO
     * 
     * @param spaceSystem TODO
     * 
     * @param parentScrollPane TODO
     * 
     * @param editEnabled TODO
     * 
     */

    public XTCEViewerSpaceSystemDetails( XTCESpaceSystem spaceSystem,
                                         JScrollPane     parentScrollPane,
                                         boolean         editEnabled ) {
        initComponents();
        spaceSystem_      = spaceSystem;
        parentScrollPane_ = parentScrollPane;
        initializeFields();
        setEditable( editEnabled );
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        longDescriptionLabel = new javax.swing.JLabel();
        longDescriptionScrollPane = new javax.swing.JScrollPane();
        longDescriptionText = new javax.swing.JTextArea();
        filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
        attributesPanel = new javax.swing.JPanel();
        spaceSystemAttributesPanel = new org.xtce.apps.editor.ui.XTCEViewerSpaceSystemAttributes();
        spaceSystemAliasSetPanel = new org.xtce.apps.editor.ui.XTCEViewerAliasSet();
        spaceSystemAuthorSetPanel = new org.xtce.apps.editor.ui.XTCEViewerAuthorSet();
        spaceSystemNoteSetPanel = new org.xtce.apps.editor.ui.XTCEViewerNoteSet();
        spaceSystemHistorySetPanel = new org.xtce.apps.editor.ui.XTCEViewerHistorySet();

        longDescriptionLabel.setText("Long Description");

        longDescriptionText.setColumns(20);
        longDescriptionText.setLineWrap(true);
        longDescriptionText.setRows(2);
        longDescriptionText.setWrapStyleWord(true);
        longDescriptionScrollPane.setViewportView(longDescriptionText);

        javax.swing.GroupLayout attributesPanelLayout = new javax.swing.GroupLayout(attributesPanel);
        attributesPanel.setLayout(attributesPanelLayout);
        attributesPanelLayout.setHorizontalGroup(
            attributesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(attributesPanelLayout.createSequentialGroup()
                .addGroup(attributesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(spaceSystemAliasSetPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(spaceSystemAuthorSetPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(spaceSystemAttributesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );
        attributesPanelLayout.setVerticalGroup(
            attributesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(attributesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(attributesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(spaceSystemAttributesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(attributesPanelLayout.createSequentialGroup()
                        .addComponent(spaceSystemAliasSetPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(spaceSystemAuthorSetPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addGap(10, 10, 10))))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(spaceSystemHistorySetPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 876, Short.MAX_VALUE)
                    .addComponent(attributesPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(longDescriptionLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(longDescriptionScrollPane))
                    .addComponent(spaceSystemNoteSetPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(longDescriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(longDescriptionLabel)
                            .addComponent(filler1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(attributesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(spaceSystemNoteSetPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 137, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(spaceSystemHistorySetPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents


    public void setEditable( boolean editEnabled ) {

        longDescriptionText.setEditable( editEnabled );
        spaceSystemAttributesPanel.setEditable( editEnabled );
        spaceSystemAliasSetPanel.setEditable( editEnabled );
        spaceSystemAuthorSetPanel.setEditable( editEnabled );
        spaceSystemHistorySetPanel.setEditable( editEnabled );
        spaceSystemNoteSetPanel.setEditable( editEnabled );

    }

    public void sizeChanged() {
        setPreferredSize( getPreferredSize() );
        revalidate();
        repaint();
        parentScrollPane_.revalidate();
        parentScrollPane_.repaint();
    }

    private void initializeFields() {

        longDescriptionText.setText( spaceSystem_.getLongDescription() );
        spaceSystemAttributesPanel.setSpaceSystem( spaceSystem_ );
        spaceSystemAliasSetPanel.setSpaceSystem( spaceSystem_ );
        spaceSystemAuthorSetPanel.setSpaceSystem( spaceSystem_ );
        spaceSystemHistorySetPanel.setSpaceSystem( spaceSystem_, this );
        spaceSystemNoteSetPanel.setSpaceSystem( spaceSystem_, this );

    }

    // Private Data Members

    private XTCESpaceSystem spaceSystem_      = null;
    private JScrollPane     parentScrollPane_ = null;


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel attributesPanel;
    private javax.swing.Box.Filler filler1;
    private javax.swing.JLabel longDescriptionLabel;
    private javax.swing.JScrollPane longDescriptionScrollPane;
    private javax.swing.JTextArea longDescriptionText;
    private org.xtce.apps.editor.ui.XTCEViewerAliasSet spaceSystemAliasSetPanel;
    private org.xtce.apps.editor.ui.XTCEViewerSpaceSystemAttributes spaceSystemAttributesPanel;
    private org.xtce.apps.editor.ui.XTCEViewerAuthorSet spaceSystemAuthorSetPanel;
    private org.xtce.apps.editor.ui.XTCEViewerHistorySet spaceSystemHistorySetPanel;
    private org.xtce.apps.editor.ui.XTCEViewerNoteSet spaceSystemNoteSetPanel;
    // End of variables declaration//GEN-END:variables
}
